export class Ossutil{
  async upload(file) {
    let OSS = require('ali-oss');

    let client = new OSS({
      region: 'oss-cn-chengdu',
      accessKeyId: 'LTAI5tKbKKZo33r8EpDqgGWH',
      accessKeySecret: 'wPzuRowwhcB7brUAwDfTcEIo8hAnBI',
      bucket: 'jingzai-pethome',
    });
    //此时可以自行将文件上传至服务器
    try {
      console.log(new Date().getTime())
      var ti = new Date().getTime()
      let result = await client.put('/img/' + ti + '.jpg', file)
      console.log(result)
      console.log("图片"+result.url)
    } catch (e) {
      console.log(e);
    }
  }
}
